package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMPmdlno08{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public SelectResultRset SELECT_PMDLNO(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	SELECT");
		sql.append("	TRIM(NVL(MDLNO      ,'')) AS MDLNO      ,");
		sql.append("	TRIM(NVL(SUP_CD     ,'')) AS SUP_CD     ,");
		sql.append("	TRIM(NVL(MFC_CD     ,'')) AS MFC_CD     ,");
		sql.append("	TRIM(NVL(SLS_DEPT_CD,'')) AS SLS_DEPT_CD,");
		sql.append("	TRIM(NVL(CLR_CD     ,'')) AS CLR_CD     ,");
		sql.append("	TRIM(NVL(BRND_CD    ,'')) AS BRND_CD    ,");
		sql.append("	TRIM(NVL(O_MDLNO    ,'')) AS O_MDLNO    ,");
		sql.append("	TRIM(NVL(HS_CD      ,'')) AS HS_CD      ,");
		sql.append("	TRIM(NVL(ACC_CAT    ,'')) AS ACC_CAT    ,");
		sql.append("	TRIM(NVL(OVS_CAT    ,'')) AS OVS_CAT    ,");
		sql.append("	TRIM(NVL(AVD_ID     ,'')) AS AVD_ID     ,");
		sql.append("	TRIM(NVL(R_QTY_ID   ,'')) AS R_QTY_ID   ,");
		sql.append("	TRIM(NVL(M_ACC_QTY  ,'')) AS M_ACC_QTY  ,");
		sql.append("	TRIM(NVL(DEC_P      ,'')) AS DEC_P      ,");
		sql.append("	TRIM(NVL(UNIT_CD    ,'')) AS UNIT_CD    ,");
		sql.append("	TRIM(NVL(IND_MDLNO  ,'')) AS IND_MDLNO  ,");
		sql.append("	TRIM(NVL(KIT_ID     ,'')) AS KIT_ID     ,");
		sql.append("	TRIM(NVL(CCM_ID     ,'')) AS CCM_ID     ,");
		sql.append("	TRIM(NVL(CMDY_NM    ,'')) AS CMDY_NM    ,");
		sql.append("	TRIM(NVL(DEPT       ,'')) AS DEPT       ,");
		sql.append("	TRIM(NVL(NM         ,'')) AS NM         ,");
		sql.append("	TRIM(NVL(PTNR_CD    ,'')) AS PTNR_CD    ,");
		sql.append("	TRIM(NVL(DESC1      ,'')) AS DESC1      ,");
		sql.append("	TRIM(NVL(DESC2      ,'')) AS DESC2      ,");
		sql.append("	TRIM(NVL(DESC3      ,'')) AS DESC3      ,");
		sql.append("	TRIM(NVL(DESC4      ,'')) AS DESC4      ,");
		sql.append("	TRIM(NVL(DESC5      ,'')) AS DESC5      ,");
		sql.append("	TRIM(NVL(DESC6      ,'')) AS DESC6      ,");
		sql.append("	TRIM(NVL(DESC7      ,'')) AS DESC7      ,");
		sql.append("	TRIM(NVL(DESC8      ,'')) AS DESC8      ,");
		sql.append("	TRIM(NVL(DESC9      ,'')) AS DESC9      ,");
		sql.append("	TRIM(NVL(DESC10     ,'')) AS DESC10     ,");
		sql.append("	TRIM(NVL(DESC11     ,'')) AS DESC11     ,");
		sql.append("	TRIM(NVL(DESC12     ,'')) AS DESC12     ,");
		sql.append("	TRIM(NVL(DESC13     ,'')) AS DESC13     ,");
		sql.append("	TRIM(NVL(DESC14     ,'')) AS DESC14     ,");
		sql.append("	TRIM(NVL(DESC15     ,'')) AS DESC15     ,");
		sql.append("	TRIM(NVL(DESC16     ,'')) AS DESC16     ,");
		sql.append("	TRIM(NVL(DESC17     ,'')) AS DESC17     ,");
		sql.append("	TRIM(NVL(DESC18     ,'')) AS DESC18     ,");
		sql.append("	TRIM(NVL(DESC19     ,'')) AS DESC19     ,");
		sql.append("	TRIM(NVL(DESC20     ,'')) AS DESC20     ,");
		sql.append("	TRIM(NVL(DEL_TYP    ,'')) AS DEL_TYP    ,");
		sql.append("	TRIM(NVL(RGS_PGM_NM  ,'')) AS RGS_PGM_NM  ,");
		sql.append("	TRIM(NVL(RGS_USR_ID  ,'')) AS RGS_USR_ID  ,");
		sql.append("	TO_CHAR(NVL(RGS_DTTM,''),'YYYYMMDDHH24MISS') AS RGS_DTTM      ,");
		sql.append("	TRIM(NVL(CHG_PGM_NM  ,'')) AS CHG_PGM_NM  ,");
		sql.append("	TRIM(NVL(CHG_USR_ID  ,'')) AS CHG_USR_ID  ,");
		sql.append("	TO_CHAR(NVL(CHG_DTTM,''),'YYYYMMDDHH24MISS') AS CHG_DTTM      ,");
		sql.append("	TRIM(NVL(CHG_TMS     ,'')) AS CHG_TMS        ");
		sql.append("	FROM PMDLNO");
		sql.append("	WHERE ");
		sql.append("	MDLNO "+((getString("MDLNO").equals(""))?" is null ":"=")+getString("MDLNO")+"  ");
		sql.append("	AND SUP_CD "+((getString("SUP_CD").equals(""))?" is null ":"=")+getString("SUP_CD")+"");
		sql.append("	");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_PPRC(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	SELECT");
		sql.append("	TRIM(NVL(MDLNO       ,'')) AS MDLNO       ,");
		sql.append("	TRIM(NVL(SUP_CD      ,'')) AS SUP_CD      ,");
		sql.append("	TRIM(NVL(PACK_STYL_CD,'')) AS PACK_STYL_CD,");
		sql.append("	TRIM(NVL(PER_PACK    ,'')) AS PER_PACK    ,");
		sql.append("	TRIM(NVL(Q_DEC_PNT   ,'')) AS Q_DEC_PNT   ,");
		sql.append("	TRIM(NVL(NET_WT      ,'')) AS NET_WT      ,");
		sql.append("	TRIM(NVL(GRS_WT      ,'')) AS GRS_WT      ,");
		sql.append("	TRIM(NVL(MN          ,'')) AS MN          ,");
		sql.append("	TRIM(NVL(WIDTH       ,'')) AS WIDTH       ,");
		sql.append("	TRIM(NVL(DEPTH       ,'')) AS DEPTH       ,");
		sql.append("	TRIM(NVL(HEIGHT      ,'')) AS HEIGHT      ,");
		sql.append("	TRIM(NVL(END_USR_CD  ,'')) AS END_USR_CD  ,");
		sql.append("	TRIM(NVL(TERM_CD     ,'')) AS TERM_CD     ,");
		sql.append("	TRIM(NVL(TERM_ID     ,'')) AS TERM_ID     ,");
		sql.append("	TRIM(NVL(CRCY_CD     ,'')) AS CRCY_CD     ,");
		sql.append("	TRIM(NVL(PAYE_CD     ,'')) AS PAYE_CD     ,");
		sql.append("	TRIM(NVL(QTY_P_PRIZ  ,'')) AS QTY_P_PRIZ  ,");
		sql.append("	TRIM(NVL(P_DEC_PNT   ,'')) AS P_DEC_PNT   ,");
		sql.append("	TRIM(NVL(UNIT_CD     ,'')) AS UNIT_CD     ,");
		sql.append("	TRIM(NVL(AVBL_DT1    ,'')) AS AVBL_DT1    ,");
		sql.append("	TRIM(NVL(VALD_DT1    ,'')) AS VALD_DT1    ,");
		sql.append("	TRIM(NVL(UNIT_P1     ,'')) AS UNIT_P1     ,");
		sql.append("	TRIM(NVL(U_P_DEC_PNT1,'')) AS U_P_DEC_PNT1,");
		sql.append("	TRIM(NVL(EX_RT1      ,'')) AS EX_RT1      ,");
		sql.append("	TRIM(NVL(E_R_DEC_PNT1,'')) AS E_R_DEC_PNT1,");
		sql.append("	TRIM(NVL(AVBL_DT2    ,'')) AS AVBL_DT2    ,");
		sql.append("	TRIM(NVL(VALD_DT2    ,'')) AS VALD_DT2    ,");
		sql.append("	TRIM(NVL(UNIT_P2     ,'')) AS UNIT_P2     ,");
		sql.append("	TRIM(NVL(U_P_DEC_PNT2,'')) AS U_P_DEC_PNT2,");
		sql.append("	TRIM(NVL(EX_RT2      ,'')) AS EX_RT2      ,");
		sql.append("	TRIM(NVL(E_R_DEC_PNT ,'')) AS E_R_DEC_PNT ,");
		sql.append("	TRIM(NVL(TMP_P_ID1   ,'')) AS TMP_P_ID1   ,");
		sql.append("	TRIM(NVL(TMP_P_ID2   ,'')) AS TMP_P_ID2   ,");
		sql.append("	TRIM(NVL(MIN_ACC_QTY ,'')) AS MIN_ACC_QTY ,");
		sql.append("	TRIM(NVL(M_A_DEC_PNT ,'')) AS M_A_DEC_PNT ,");
		sql.append("	TRIM(NVL(DEL_TYP     ,'')) AS DEL_TYP     ,");
		sql.append("	TRIM(NVL(RGS_PGM_NM  ,'')) AS RGS_PGM_NM  ,");
		sql.append("	TRIM(NVL(RGS_USR_ID  ,'')) AS RGS_USR_ID  ,");
		sql.append("	TO_CHAR(NVL(RGS_DTTM,''),'YYYYMMDDHH24MISS') AS RGS_DTTM      ,");
		sql.append("	TRIM(NVL(CHG_PGM_NM  ,'')) AS CHG_PGM_NM  ,");
		sql.append("	TRIM(NVL(CHG_USR_ID  ,'')) AS CHG_USR_ID  ,");
		sql.append("	TO_CHAR(NVL(CHG_DTTM,''),'YYYYMMDDHH24MISS') AS CHG_DTTM      ,");
		sql.append("	TRIM(NVL(CHG_TMS     ,'')) AS CHG_TMS     ");
		sql.append("	FROM PPRC ");
		sql.append("	WHERE ");
		sql.append("	MDLNO "+((getString("MDLNO").equals(""))?" is null ":"=")+getString("MDLNO")+"  ");
		sql.append("	AND SUP_CD "+((getString("SUP_CD").equals(""))?" is null ":"=")+getString("SUP_CD")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}


	public void setMDLNO(String value){
		if(value==null) {
			paramsString.remove("MDLNO");
			return;
		}
		paramsString.put("MDLNO",value);
	}


	public void setSUP_CD(String value){
		if(value==null) {
			paramsString.remove("SUP_CD");
			return;
		}
		paramsString.put("SUP_CD",value);
	}


}
